<!DOCTYPE html>



  


<html class="theme-next gemini use-motion" lang="zh-Hans">
<head>
  <meta charset="UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>
<meta name="theme-color" content="#222">









<meta http-equiv="Cache-Control" content="no-transform" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
















  
  
  <link href="/lib/fancybox/source/jquery.fancybox.css?v=2.1.5" rel="stylesheet" type="text/css" />







<link href="/lib/font-awesome/css/font-awesome.min.css?v=4.6.2" rel="stylesheet" type="text/css" />

<link href="/css/main.css?v=5.1.4" rel="stylesheet" type="text/css" />


  <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png?v=5.1.4">


  <link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32-next.png?v=5.1.4">


  <link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16-next.png?v=5.1.4">


  <link rel="mask-icon" href="/images/logo.svg?v=5.1.4" color="#222">





  <meta name="keywords" content="mybatis," />










<meta name="description" content="Mybatis一、简介Mybatis是一款优秀的持久层框架，支持自定义的SQL、存储过程、及高级映射。  官方文档https:&#x2F;&#x2F;mybatis.org&#x2F;mybatis-3&#x2F;zh&#x2F;index.html 快速入门1234567891011&lt;dependency&gt;            &lt;groupId&gt;org.mybatis&lt;&#x2F;groupId&gt;">
<meta property="og:type" content="article">
<meta property="og:title" content="Mybatis">
<meta property="og:url" content="https://gitee.com/htt-sub/htt-sub/2023/10/28/Mybatis/index.html">
<meta property="og:site_name" content="黄宏涛">
<meta property="og:description" content="Mybatis一、简介Mybatis是一款优秀的持久层框架，支持自定义的SQL、存储过程、及高级映射。  官方文档https:&#x2F;&#x2F;mybatis.org&#x2F;mybatis-3&#x2F;zh&#x2F;index.html 快速入门1234567891011&lt;dependency&gt;            &lt;groupId&gt;org.mybatis&lt;&#x2F;groupId&gt;">
<meta property="og:locale">
<meta property="og:image" content="https://gitee.com/htt-sub/pic-go/raw/master/images/image-20231028090158735.png">
<meta property="og:image" content="https://gitee.com/htt-sub/pic-go/raw/master/images/image-20231028131635696.png">
<meta property="og:image" content="https://gitee.com/htt-sub/pic-go/raw/master/images/image-20231028210537977.png">
<meta property="og:image" content="https://gitee.com/htt-sub/pic-go/raw/master/images/image-20231028195210413.png">
<meta property="og:image" content="https://gitee.com/htt-sub/pic-go/raw/master/images/image-20231029093137490.png">
<meta property="og:image" content="https://gitee.com/htt-sub/pic-go/raw/master/images/image-20231029093250808.png">
<meta property="og:image" content="https://gitee.com/htt-sub/pic-go/raw/master/images/image-20231029101137903.png">
<meta property="article:published_time" content="2023-10-27T16:00:00.000Z">
<meta property="article:modified_time" content="2023-10-29T02:50:55.977Z">
<meta property="article:author" content="黄宏涛">
<meta property="article:tag" content="mybatis">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="https://gitee.com/htt-sub/pic-go/raw/master/images/image-20231028090158735.png">



<script type="text/javascript" id="hexo.configurations">
  var NexT = window.NexT || {};
  var CONFIG = {
    root: '',
    scheme: 'Gemini',
    version: '5.1.4',
    sidebar: {"position":"post","display":"post","offset":12,"b2t":false,"scrollpercent":false,"onmobile":false},
    fancybox: true,
    tabs: true,
    motion: {"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}},
    duoshuo: {
      userId: '0',
      author: '博主'
    },
    algolia: {
      applicationID: '',
      apiKey: '',
      indexName: '',
      hits: {"per_page":10},
      labels: {"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}
    }
  };
</script>



  <link rel="canonical" href="https://gitee.com/htt-sub/htt-sub/2023/10/28/Mybatis/"/>





  <title>Mybatis | 黄宏涛</title>
  








<meta name="generator" content="Hexo 6.3.0"></head>

<body itemscope itemtype="http://schema.org/WebPage" lang="zh-Hans">

  
  
    
  

  <div class="container sidebar-position-post page-post-detail">
    <div class="headband"></div>

    <header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-wrapper">
  <div class="site-meta ">
    

    <div class="custom-logo-site-title">
      <a href="/"  class="brand" rel="start">
        <span class="logo-line-before"><i></i></span>
        <span class="site-title">黄宏涛</span>
        <span class="logo-line-after"><i></i></span>
      </a>
    </div>
      
        <p class="site-subtitle"></p>
      
  </div>

  <div class="site-nav-toggle">
    <button>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
    </button>
  </div>
</div>

<nav class="site-nav">
  

  
    <ul id="menu" class="menu">
      
        
        <li class="menu-item menu-item-home">
          <a href="/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-home"></i> <br />
            
            首页
          </a>
        </li>
      
        
        <li class="menu-item menu-item-categories">
          <a href="/categories/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-th"></i> <br />
            
            分类
          </a>
        </li>
      
        
        <li class="menu-item menu-item-tags">
          <a href="/tags/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-tags"></i> <br />
            
            标签
          </a>
        </li>
      

      
    </ul>
  

  
</nav>



 </div>
    </header>

    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
          <div id="content" class="content">
            

  <div id="posts" class="posts-expand">
    

  

  
  
  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="https://gitee.com/htt-sub/htt-sub/2023/10/28/Mybatis/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/images/avatar.png">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="黄宏涛">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">Mybatis</h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2023-10-28T00:00:00+08:00">
                2023-10-28
              </time>
            

            

            
          </span>

          
            <span class="post-category" >
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">分类于</span>
              
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/SSM/" itemprop="url" rel="index">
                    <span itemprop="name">SSM</span>
                  </a>
                </span>

                
                
              
            </span>
          

          
            
          

          
          

          

          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        <h2 id="Mybatis"><a href="#Mybatis" class="headerlink" title="Mybatis"></a>Mybatis</h2><h2 id="一、简介"><a href="#一、简介" class="headerlink" title="一、简介"></a>一、简介</h2><p>Mybatis是一款优秀的持久层框架，支持自定义的SQL、存储过程、及高级映射。</p>
<p><img src="https://gitee.com/htt-sub/pic-go/raw/master/images/image-20231028090158735.png" alt="image-20231028090158735"></p>
<h3 id="官方文档"><a href="#官方文档" class="headerlink" title="官方文档"></a>官方文档</h3><p><strong><a target="_blank" rel="noopener" href="https://mybatis.org/mybatis-3/zh/index.html">https://mybatis.org/mybatis-3/zh/index.html</a></strong></p>
<h3 id="快速入门"><a href="#快速入门" class="headerlink" title="快速入门"></a>快速入门</h3><figure class="highlight yaml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><span class="line"><span class="string">&lt;dependency&gt;</span></span><br><span class="line">            <span class="string">&lt;groupId&gt;org.mybatis&lt;/groupId&gt;</span></span><br><span class="line">            <span class="string">&lt;artifactId&gt;mybatis&lt;/artifactId&gt;</span></span><br><span class="line">            <span class="string">&lt;version&gt;3.5.11&lt;/version&gt;</span></span><br><span class="line">        <span class="string">&lt;/dependency&gt;</span></span><br><span class="line"></span><br><span class="line">        <span class="string">&lt;dependency&gt;</span></span><br><span class="line">            <span class="string">&lt;groupId&gt;mysql&lt;/groupId&gt;</span></span><br><span class="line">            <span class="string">&lt;artifactId&gt;mysql-connector-java&lt;/artifactId&gt;</span></span><br><span class="line">            <span class="string">&lt;version&gt;8.0.25&lt;/version&gt;</span></span><br><span class="line">        <span class="string">&lt;/dependency&gt;</span></span><br></pre></td></tr></table></figure>

<ul>
<li>xxxMapper接口  <strong>规定方法</strong></li>
<li>xxxMapper.xml  <strong>接口对应方法的SQL语句</strong></li>
</ul>
<blockquote>
<p><strong>UserMapper接口</strong></p>
</blockquote>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">/**</span></span><br><span class="line"><span class="comment"> * 查询用户信息</span></span><br><span class="line"><span class="comment"> */</span></span><br><span class="line"><span class="keyword">public</span> <span class="keyword">interface</span> <span class="title class_">UserMapper</span> &#123;</span><br><span class="line"></span><br><span class="line">   User <span class="title function_">queryById</span><span class="params">(<span class="type">int</span> id)</span>;</span><br><span class="line"></span><br><span class="line">   <span class="keyword">void</span> <span class="title function_">deleteById</span><span class="params">(<span class="type">int</span> id)</span>;</span><br><span class="line"></span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<blockquote>
<p><strong>UserMapper.xml</strong></p>
</blockquote>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br></pre></td><td class="code"><pre><span class="line">&lt;?xml version=<span class="string">&quot;1.0&quot;</span> encoding=<span class="string">&quot;UTF-8&quot;</span>?&gt;</span><br><span class="line">&lt;!DOCTYPE mapper PUBLIC <span class="string">&quot;-//mybatis.org//DTD Mapper 3.0//EN&quot;</span></span><br><span class="line">        <span class="string">&quot;http://mybatis.org/dtd/mybatis-3-mapper.dtd&quot;</span>&gt;</span><br><span class="line">&lt;!--命名空间：找到所在的mapper接口的位置--&gt;</span><br><span class="line">&lt;mapper namespace=<span class="string">&quot;com.atguigu.jdbc.config.mapper.UserMapper&quot;</span>&gt;</span><br><span class="line">    &lt;!--sql语句代码</span><br><span class="line">        id和方法名一样</span><br><span class="line">    --&gt;</span><br><span class="line">    &lt;select id=<span class="string">&quot;queryById&quot;</span> resultType=<span class="string">&quot;user&quot;</span>&gt;</span><br><span class="line">        select * from user where id=#&#123;id&#125;</span><br><span class="line">    &lt;/select&gt;</span><br><span class="line"></span><br><span class="line">    &lt;delete id=<span class="string">&quot;deleteById&quot;</span>&gt;</span><br><span class="line">        delete from user where id=#&#123;id&#125;</span><br><span class="line">    &lt;/delete&gt;</span><br><span class="line">&lt;/mapper&gt;</span><br></pre></td></tr></table></figure>

<blockquote>
<p>Mybatis-config.xml配置文件</p>
</blockquote>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br></pre></td><td class="code"><pre><span class="line">&lt;?xml version=<span class="string">&quot;1.0&quot;</span> encoding=<span class="string">&quot;UTF-8&quot;</span>?&gt;</span><br><span class="line">&lt;!DOCTYPE configuration PUBLIC <span class="string">&quot;-//mybatis.org//DTD Config 3.0//EN&quot;</span> <span class="string">&quot;http://mybatis.org/dtd/mybatis-3-config.dtd&quot;</span>&gt;</span><br><span class="line">&lt;configuration&gt;</span><br><span class="line">    &lt;properties resource=<span class="string">&quot;jdbc.properties&quot;</span> /&gt;</span><br><span class="line">    &lt;typeAliases&gt;</span><br><span class="line">        &lt;typeAlias type=<span class="string">&quot;com.atguigu.jdbc.config.pojo.User&quot;</span> alias=<span class="string">&quot;User&quot;</span> /&gt;</span><br><span class="line">    &lt;/typeAliases&gt;</span><br><span class="line">    &lt;environments <span class="keyword">default</span>=<span class="string">&quot;development&quot;</span>&gt;</span><br><span class="line">        &lt;environment id=<span class="string">&quot;development&quot;</span>&gt;</span><br><span class="line">            &lt;transactionManager type=<span class="string">&quot;JDBC&quot;</span> /&gt;</span><br><span class="line">            &lt;dataSource type=<span class="string">&quot;POOLED&quot;</span>&gt;</span><br><span class="line">                &lt;property name=<span class="string">&quot;driver&quot;</span> value=<span class="string">&quot;$&#123;jdbc.driver&#125;&quot;</span> /&gt;</span><br><span class="line">                &lt;property name=<span class="string">&quot;url&quot;</span> value=<span class="string">&quot;$&#123;jdbc.url&#125;&quot;</span> /&gt;</span><br><span class="line">                &lt;property name=<span class="string">&quot;username&quot;</span> value=<span class="string">&quot;$&#123;jdbc.username&#125;&quot;</span> /&gt;</span><br><span class="line">                &lt;property name=<span class="string">&quot;password&quot;</span> value=<span class="string">&quot;$&#123;jdbc.password&#125;&quot;</span> /&gt;</span><br><span class="line">            &lt;/dataSource&gt;</span><br><span class="line">        &lt;/environment&gt;</span><br><span class="line">    &lt;/environments&gt;</span><br><span class="line"></span><br><span class="line">    &lt;!--指定mybatis映射文件的具体位置</span><br><span class="line">        resource属性：指定mapper映射文件的存储位置，需要一个以类路径为基准的相对路径</span><br><span class="line">    --&gt;</span><br><span class="line">    &lt;mappers&gt;</span><br><span class="line">        &lt;mapper resource=<span class="string">&quot;mappers/UserMapper.xml&quot;</span> /&gt;</span><br><span class="line">    &lt;/mappers&gt;</span><br><span class="line">    </span><br><span class="line">    &lt;!-- 将包内的映射器接口全部注册为映射器 --&gt;</span><br><span class="line">	&lt;mappers&gt;</span><br><span class="line">  	&lt;<span class="keyword">package</span> name=<span class="string">&quot;org.mybatis.builder&quot;</span>/&gt;</span><br><span class="line">	&lt;/mappers&gt;  </span><br><span class="line">    </span><br><span class="line">&lt;/configuration&gt;</span><br></pre></td></tr></table></figure>

<blockquote>
<p><strong>测试</strong></p>
</blockquote>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br></pre></td><td class="code"><pre><span class="line">ublic <span class="keyword">void</span> <span class="title function_">test</span><span class="params">()</span> <span class="keyword">throws</span> IOException, InterruptedException &#123;</span><br><span class="line">        <span class="comment">//读取外部配置文件</span></span><br><span class="line">        <span class="type">InputStream</span> <span class="variable">ips</span> <span class="operator">=</span> Resources.getResourceAsStream(<span class="string">&quot;mybatis-config.xml&quot;</span>);</span><br><span class="line">        <span class="comment">//创建SQLSessionFactory</span></span><br><span class="line">        <span class="type">SqlSessionFactory</span> <span class="variable">sqlSessionFactory</span> <span class="operator">=</span> <span class="keyword">new</span> <span class="title class_">SqlSessionFactoryBuilder</span>().build(ips);</span><br><span class="line">        <span class="comment">//创建SQLsession</span></span><br><span class="line">        <span class="comment">//openSession(true)表示事务自动提价，不用写sqlSession.commit()</span></span><br><span class="line">        <span class="type">SqlSession</span> <span class="variable">sqlSession</span> <span class="operator">=</span> sqlSessionFactory.openSession();</span><br><span class="line">        <span class="comment">//获取接口代理对象，调用代理对象的方法</span></span><br><span class="line">        <span class="type">UserMapper</span> <span class="variable">mapper</span> <span class="operator">=</span> sqlSession.getMapper(UserMapper.class);</span><br><span class="line">        <span class="type">User</span> <span class="variable">user</span> <span class="operator">=</span> mapper.queryById(<span class="number">1</span>);</span><br><span class="line">        System.out.println(user);</span><br><span class="line"></span><br><span class="line">        sqlSession.commit();</span><br><span class="line">        sqlSession.close();</span><br><span class="line"></span><br><span class="line">    &#125;</span><br></pre></td></tr></table></figure>

<h3 id="Mybatis原理"><a href="#Mybatis原理" class="headerlink" title="Mybatis原理"></a>Mybatis原理</h3><p>Mybatis是对ibatis的封装。</p>
<p><img src="https://gitee.com/htt-sub/pic-go/raw/master/images/image-20231028131635696.png" alt="image-20231028131635696"></p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line">	<span class="type">SqlSession</span> <span class="variable">sqlSession</span> <span class="operator">=</span> sqlSessionFactory.openSession();</span><br><span class="line">      <span class="comment">//获取接口代理对象，调用代理对象的方法,就会查找mapper接口的方法</span></span><br><span class="line"><span class="comment">//jdk动态代理技术生成mapper代理对象</span></span><br><span class="line">      <span class="type">UserMapper</span> <span class="variable">mapper</span> <span class="operator">=</span> sqlSession.getMapper(UserMapper.class);</span><br><span class="line"><span class="comment">//内部拼接接口的全限定符号，方法名，去查找SQL语句标签</span></span><br><span class="line"><span class="comment">//拼接：类的全限定符，方法名，整合参数---》ibatis对应方法传入对应参数</span></span><br><span class="line"><span class="comment">//Mybatis底层依然用ibatis，只不过有固定的模式</span></span><br><span class="line">      <span class="type">User</span> <span class="variable">user</span> <span class="operator">=</span> mapper.queryById(<span class="number">1</span>);</span><br></pre></td></tr></table></figure>

<h2 id="二、基本使用"><a href="#二、基本使用" class="headerlink" title="二、基本使用"></a>二、基本使用</h2><h3 id="2-1-向SQL语句传参"><a href="#2-1-向SQL语句传参" class="headerlink" title="2.1 向SQL语句传参"></a>2.1 向SQL语句传参</h3><blockquote>
<p><strong>日志输出设置</strong></p>
</blockquote>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">&lt;settings&gt;</span><br><span class="line">        &lt;!--开启了日志输出--&gt;</span><br><span class="line">        &lt;setting name=<span class="string">&quot;logImpl&quot;</span> value=<span class="string">&quot;STDOUT_LOGGING&quot;</span>/&gt;</span><br><span class="line">&lt;/settings&gt;</span><br></pre></td></tr></table></figure>

<h3 id="2-2-和-区别"><a href="#2-2-和-区别" class="headerlink" title="2.2 #{}和${}区别"></a>2.2 #{}和${}区别</h3><ul>
<li>#{}（推荐使用） 占位符+赋值，可以防止数据注入攻击</li>
<li>${}  字符串拼接，如果是动态的列名，可以用这个,  $<strong>{columnName}&#x3D;</strong>#{columnValue}</li>
</ul>
<h3 id="2-3-单个实体类插入"><a href="#2-3-单个实体类插入" class="headerlink" title="2.3 单个实体类插入"></a>2.3 单个实体类插入</h3><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">&lt;insert id=<span class="string">&quot;insert&quot;</span> parameterType=<span class="string">&quot;User&quot;</span>&gt;</span><br><span class="line">        insert into <span class="title function_">user</span><span class="params">(id,name,age)</span> values (#&#123;id&#125;,#&#123;name&#125;,#&#123;age&#125;)</span><br><span class="line">&lt;/insert&gt;</span><br></pre></td></tr></table></figure>

<h3 id="2-4-多个简单类型传入"><a href="#2-4-多个简单类型传入" class="headerlink" title="2.4 多个简单类型传入"></a>2.4 多个简单类型传入</h3><p>单个参数，#{}可以随便写，&#x3D;&#x3D;<strong>多个参数，要加@Param注解</strong>&#x3D;&#x3D;</p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">//根据姓名和年龄查询用户</span></span><br><span class="line">   List&lt;User&gt; <span class="title function_">queryByNameAndAge</span><span class="params">(<span class="meta">@Param(&quot;name&quot;)</span> String name, <span class="meta">@Param(&quot;age&quot;)</span> <span class="type">int</span> age)</span>;</span><br><span class="line"></span><br><span class="line"></span><br><span class="line">&lt;!--单个参数，#&#123;&#125;可以随便写，多个参数，要加<span class="meta">@Param</span>注解--&gt;</span><br><span class="line">   &lt;select id=<span class="string">&quot;queryByNameAndAge&quot;</span> resultType=<span class="string">&quot;User&quot;</span>&gt;</span><br><span class="line">       select * from user where name=#&#123;name&#125; and age=#&#123;age&#125;;</span><br><span class="line">   &lt;/select&gt;</span><br></pre></td></tr></table></figure>

<h3 id="2-3-返回类型"><a href="#2-3-返回类型" class="headerlink" title="2.3 返回类型"></a>2.3 返回类型</h3><p>resultType返回类型，<strong>Mybatis提供了常用类型别名</strong>，如string,double ,Integer,int</p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">&lt;select id=<span class="string">&quot;queryByNameAndAge&quot;</span> resultType=<span class="string">&quot;string&quot;</span>&gt;</span><br><span class="line">       select * from user where name=#&#123;name&#125; and age=#&#123;age&#125;;</span><br><span class="line">   &lt;/select&gt;</span><br></pre></td></tr></table></figure>

<p><strong>类的别名</strong></p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line">&lt;typeAliases&gt;</span><br><span class="line">    &lt;typeAlias type=<span class="string">&quot;com.atguigu.jdbc.config.pojo.User&quot;</span> alias=<span class="string">&quot;User&quot;</span> /&gt;</span><br><span class="line">&lt;/typeAliases&gt;</span><br><span class="line">    </span><br><span class="line"> &lt;!--整个包定义别名，默认所有类首字母小写,或者用<span class="meta">@Alias</span>注解在类上--&gt;</span><br><span class="line">    &lt;typeAliases&gt;</span><br><span class="line">    &lt;<span class="keyword">package</span> name=<span class="string">&quot;com.atguigu.jdbc.config.pojo&quot;</span> /&gt;</span><br><span class="line">    &lt;/typeAliases&gt;</span><br></pre></td></tr></table></figure>

<blockquote>
<p><strong>驼峰命名</strong></p>
</blockquote>
<p><strong>返回单个实体类型，列名要和属性名一致</strong>，这样才可以进行实体类的属性映射。</p>
<p>Mybatis的驼峰命名可以即将  user_id 映射为  userId</p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">&lt;settings&gt;</span><br><span class="line">       &lt;!--驼峰命名--&gt;</span><br><span class="line">       &lt;setting name=<span class="string">&quot;mapUnderscoreToCamelCase&quot;</span> value=<span class="string">&quot;true&quot;</span>/&gt;</span><br><span class="line">   &lt;/settings&gt;</span><br></pre></td></tr></table></figure>

<h3 id="2-4-返回Map类型"><a href="#2-4-返回Map类型" class="headerlink" title="2.4 返回Map类型"></a>2.4 返回Map类型</h3><p>resultType&#x3D;”map”</p>
<h3 id="2-5-返回List类型"><a href="#2-5-返回List类型" class="headerlink" title="2.5 返回List类型"></a>2.5 返回List类型</h3><p>&#x3D;&#x3D;返回值是集合，resultType不需要指定集合类型&#x3D;&#x3D;，只需要指定反省即可</p>
<ul>
<li>List<String>    resultType&#x3D;”string”</li>
<li>List<User>     resultType&#x3D;”user”</li>
</ul>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">&lt;select id=<span class="string">&quot;queryByNameAndAge&quot;</span> resultType=<span class="string">&quot;User&quot;</span>&gt;</span><br><span class="line">       select * from user where name=#&#123;name&#125; and age=#&#123;age&#125;;</span><br><span class="line">   &lt;/select&gt;</span><br></pre></td></tr></table></figure>

<h3 id="2-6-自动提交事务和自增主键"><a href="#2-6-自动提交事务和自增主键" class="headerlink" title="2.6 自动提交事务和自增主键"></a>2.6 自动提交事务和自增主键</h3><ul>
<li>useGeneratedKeys&#x3D;”true”  数据库自增的主键值</li>
<li>keyColumn&#x3D;”id”  主键列的值</li>
<li>keyProperty&#x3D;”id”  接收主键值的属性</li>
</ul>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">&lt;insert id=<span class="string">&quot;insert&quot;</span> parameterType=<span class="string">&quot;User&quot;</span> useGeneratedKeys=<span class="string">&quot;true&quot;</span> keyColumn=<span class="string">&quot;id&quot;</span>       keyProperty=<span class="string">&quot;id&quot;</span>&gt;</span><br><span class="line">        insert into <span class="title function_">user</span><span class="params">(id,name,age)</span> values (#&#123;id&#125;,#&#123;name&#125;,#&#123;age&#125;)</span><br><span class="line">    &lt;/insert&gt;</span><br></pre></td></tr></table></figure>

<h3 id="自定义映射关系resultMap"><a href="#自定义映射关系resultMap" class="headerlink" title="自定义映射关系resultMap"></a>自定义映射关系resultMap</h3><p><strong>列名和属性名不能用驼峰映射</strong>。能用驼峰映射的会直接用。</p>
<p>例如：userName —-&gt;user_name 可以直接驼峰映射</p>
<p>例如：uesrDesc—-&gt;desc  不能直接驼峰映射</p>
<figure class="highlight yaml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line"><span class="string">&lt;!--id是主键映射关系，result普通列映射关系--&gt;</span></span><br><span class="line">    <span class="string">&lt;resultMap</span> <span class="string">id=&quot;rMap&quot;</span> <span class="string">type=&quot;user&quot;&gt;</span></span><br><span class="line">        <span class="string">&lt;id</span> <span class="string">column=&quot;id&quot;</span> <span class="string">property=&quot;tId&quot;/&gt;</span></span><br><span class="line">        <span class="string">&lt;result</span> <span class="string">column=&quot;t_name&quot;</span> <span class="string">property=&quot;tName&quot;/&gt;</span></span><br><span class="line">    <span class="string">&lt;/resultMap&gt;</span></span><br><span class="line">    <span class="string">&lt;select</span> <span class="string">id=&quot;queryById&quot;</span> <span class="string">resultMap=&quot;rMap&quot;&gt;</span></span><br><span class="line">        <span class="string">select</span> <span class="string">*</span> <span class="string">from</span> <span class="string">user</span> <span class="string">where</span> <span class="string">id=#&#123;id&#125;</span></span><br><span class="line">    <span class="string">&lt;/select&gt;</span></span><br></pre></td></tr></table></figure>

<h2 id="三、多表映射"><a href="#三、多表映射" class="headerlink" title="三、多表映射"></a>三、多表映射</h2><p><img src="https://gitee.com/htt-sub/pic-go/raw/master/images/image-20231028210537977.png" alt="image-20231028210537977"></p>
<ol>
<li>多表查询语句使用</li>
<li>多表结果实体类设计</li>
<li>使用ResultMap完成多表结果映射</li>
</ol>
<p><img src="https://gitee.com/htt-sub/pic-go/raw/master/images/image-20231028195210413.png" alt="image-20231028195210413"></p>
<blockquote>
<p>&#x3D;&#x3D;<strong>对一映射</strong>&#x3D;&#x3D;</p>
</blockquote>
<p>根据对应订单id，查询订单和订单关联的用户信息。</p>
<p><strong>可以在订单类中添加一个客户属性</strong></p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br></pre></td><td class="code"><pre><span class="line">&lt;!--自定义映射关系--&gt;</span><br><span class="line">    &lt;resultMap id=<span class="string">&quot;orderMap&quot;</span> type=<span class="string">&quot;order&quot;</span>&gt;</span><br><span class="line">        &lt;id column=<span class="string">&quot;order_id&quot;</span> property=<span class="string">&quot;orderId&quot;</span>/&gt;</span><br><span class="line">        &lt;result column=<span class="string">&quot;order_name&quot;</span> property=<span class="string">&quot;orderName&quot;</span>/&gt;</span><br><span class="line">        &lt;result column=<span class="string">&quot;customer_id&quot;</span> property=<span class="string">&quot;customerId&quot;</span>/&gt;</span><br><span class="line">        &lt;!--对一 association对象属性赋值</span><br><span class="line">        property对象属性名</span><br><span class="line">        javaType对象类型</span><br><span class="line">        --&gt;</span><br><span class="line">        &lt;association property=<span class="string">&quot;customer&quot;</span> javaType=<span class="string">&quot;customer&quot;</span>&gt;</span><br><span class="line">            &lt;id column=<span class="string">&quot;customer_id&quot;</span> property=<span class="string">&quot;customerId&quot;</span>/&gt;</span><br><span class="line">            &lt;result column=<span class="string">&quot;customer_name&quot;</span> property=<span class="string">&quot;customerName&quot;</span>/&gt;</span><br><span class="line">        &lt;/association&gt;</span><br><span class="line">    &lt;/resultMap&gt;</span><br><span class="line">    &lt;select id=<span class="string">&quot;queryByOrderId&quot;</span>  resultMap=<span class="string">&quot;orderMap&quot;</span>&gt;</span><br><span class="line">        select * from t_order o join t_customer c</span><br><span class="line">            on o.order_id=c.customer_id</span><br><span class="line">        where o.order_id=#&#123;orderId&#125;</span><br><span class="line">    &lt;/select&gt;</span><br></pre></td></tr></table></figure>

<blockquote>
<p>&#x3D;&#x3D;<strong>对多映射</strong>&#x3D;&#x3D;</p>
</blockquote>
<p>查询所有客户信息和客户对应的订单信息</p>
<p>对多时，在当前类添加一个属性</p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">// 多个订单</span></span><br><span class="line">    <span class="keyword">private</span> List&lt;Order&gt; orderList;</span><br></pre></td></tr></table></figure>

<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br></pre></td><td class="code"><pre><span class="line">&lt;resultMap id=<span class="string">&quot;customerMap&quot;</span> type=<span class="string">&quot;customer&quot;</span>&gt;</span><br><span class="line">        &lt;id column=<span class="string">&quot;customer_id&quot;</span> property=<span class="string">&quot;customerId&quot;</span>/&gt;</span><br><span class="line">        &lt;result column=<span class="string">&quot;customer_name&quot;</span> property=<span class="string">&quot;customerName&quot;</span>/&gt;</span><br><span class="line">        &lt;!--collection给集合赋值</span><br><span class="line">            property：集合属性名</span><br><span class="line">            ofType: 集合的泛型列席</span><br><span class="line">        --&gt;</span><br><span class="line">        &lt;collection property=<span class="string">&quot;orderList&quot;</span> ofType=<span class="string">&quot;order&quot;</span>&gt;</span><br><span class="line">            &lt;id column=<span class="string">&quot;order_id&quot;</span> property=<span class="string">&quot;orderId&quot;</span>/&gt;</span><br><span class="line">            &lt;result column=<span class="string">&quot;order_name&quot;</span> property=<span class="string">&quot;orderName&quot;</span>/&gt;</span><br><span class="line">            &lt;result column=<span class="string">&quot;customer_id&quot;</span> property=<span class="string">&quot;customerId&quot;</span>/&gt;</span><br><span class="line">        &lt;/collection&gt;</span><br><span class="line">    &lt;/resultMap&gt;</span><br><span class="line"></span><br><span class="line">    &lt;select id=<span class="string">&quot;queryAll&quot;</span> resultMap=<span class="string">&quot;customerMap&quot;</span>&gt;</span><br><span class="line">        select * from t_customer t join t_order o</span><br><span class="line">            on t.customer_id=o.customer_id</span><br><span class="line">    &lt;/select&gt;</span><br></pre></td></tr></table></figure>

<h3 id="总结"><a href="#总结" class="headerlink" title="总结"></a>总结</h3><p><strong>默认resultMap会自动映射第一层开启配置。</strong>&#x3D;&#x3D;result标签可以省略，id标签不可以省略&#x3D;&#x3D;</p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br></pre></td><td class="code"><pre><span class="line">&lt;settings&gt;</span><br><span class="line">       &lt;!--自动映射，默认只映射第一层，值为FULL表示多层也会自动映射--&gt;</span><br><span class="line">       &lt;setting name=<span class="string">&quot;autoMappingBehavior&quot;</span> value=<span class="string">&quot;FULL&quot;</span>/&gt;</span><br><span class="line">   &lt;/settings&gt;</span><br><span class="line">       </span><br><span class="line">       </span><br><span class="line">       &lt;resultMap id=<span class="string">&quot;customerMap&quot;</span> type=<span class="string">&quot;customer&quot;</span>&gt;</span><br><span class="line">       &lt;id column=<span class="string">&quot;customer_id&quot;</span> property=<span class="string">&quot;customerId&quot;</span>/&gt;</span><br><span class="line">       &lt;collection property=<span class="string">&quot;orderList&quot;</span> ofType=<span class="string">&quot;order&quot;</span>&gt;</span><br><span class="line">           &lt;id column=<span class="string">&quot;order_id&quot;</span> property=<span class="string">&quot;orderId&quot;</span>/&gt;</span><br><span class="line">           &lt;result column=<span class="string">&quot;order_name&quot;</span> property=<span class="string">&quot;orderName&quot;</span>/&gt;</span><br><span class="line">           &lt;result column=<span class="string">&quot;customer_id&quot;</span> property=<span class="string">&quot;customerId&quot;</span>/&gt;</span><br><span class="line">       &lt;/collection&gt;</span><br><span class="line">   	&lt;/resultMap&gt;</span><br></pre></td></tr></table></figure>

<h2 id="四、动态语句"><a href="#四、动态语句" class="headerlink" title="四、动态语句"></a>四、动态语句</h2><blockquote>
<p><strong>if和where标签</strong></p>
</blockquote>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br></pre></td><td class="code"><pre><span class="line">&lt;!--</span><br><span class="line">    <span class="keyword">if</span>多个判断语句，要加and，</span><br><span class="line">    判断条件中的大于和小于有可能失败失败，推荐使用</span><br><span class="line">    &amp;gt;替代大于，</span><br><span class="line">    &amp;lt替代小于</span><br><span class="line"></span><br><span class="line">    where标签内，若有多个<span class="keyword">if</span>标签，</span><br><span class="line">    where标签会自动去除多余的and或or</span><br><span class="line">    --&gt;</span><br><span class="line">    &lt;select id=<span class="string">&quot;queryById&quot;</span> resultType=<span class="string">&quot;User&quot;</span>&gt;</span><br><span class="line">        select * from user</span><br><span class="line">            &lt;where&gt;</span><br><span class="line">                &lt;<span class="keyword">if</span> test=<span class="string">&quot;name!=null&quot;</span>&gt;</span><br><span class="line">                    name=#&#123;name&#125;</span><br><span class="line">                &lt;/<span class="keyword">if</span>&gt;</span><br><span class="line">                &lt;<span class="keyword">if</span> test=<span class="string">&quot;age&amp;lt;25&quot;</span>&gt;</span><br><span class="line">                    and age=#&#123;age&#125;</span><br><span class="line">                &lt;/<span class="keyword">if</span>&gt;</span><br><span class="line">            &lt;/where&gt;</span><br><span class="line">    &lt;/select&gt;</span><br></pre></td></tr></table></figure>

<blockquote>
<p><strong>Set标签</strong></p>
</blockquote>
<p>更新时使用</p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br></pre></td><td class="code"><pre><span class="line">&lt;!--</span><br><span class="line">    set标签可以去除多余的逗号，</span><br><span class="line">    set标签内至少要保证满足一个--&gt;</span><br><span class="line">    &lt;update id=<span class="string">&quot;updateById&quot;</span>&gt;</span><br><span class="line">        update user</span><br><span class="line">        &lt;set&gt;</span><br><span class="line">            &lt;<span class="keyword">if</span> test=<span class="string">&quot;name!=null&quot;</span>&gt;</span><br><span class="line">                &lt;!--注意此处有一个逗号--&gt;</span><br><span class="line">                name=#&#123;name&#125;,</span><br><span class="line">            &lt;/<span class="keyword">if</span>&gt;</span><br><span class="line">            &lt;<span class="keyword">if</span> test=<span class="string">&quot;age&amp;lt;25&quot;</span>&gt;</span><br><span class="line">                age=#&#123;age&#125;</span><br><span class="line">            &lt;/<span class="keyword">if</span>&gt;</span><br><span class="line">        &lt;/set&gt;</span><br><span class="line">        where id=#&#123;id&#125;</span><br><span class="line">    &lt;/update&gt;</span><br></pre></td></tr></table></figure>

<blockquote>
<p><strong>trim标签（了解）</strong></p>
</blockquote>
<p>可以替代where和set，自定义去除指定的前缀或后缀</p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br></pre></td><td class="code"><pre><span class="line">&lt;select id=<span class="string">&quot;queryById&quot;</span> resultType=<span class="string">&quot;User&quot;</span>&gt;</span><br><span class="line">        select * from user</span><br><span class="line">            &lt;!--前缀设置为where，前缀过滤掉and或or --&gt;</span><br><span class="line">            &lt;trim prefix=<span class="string">&quot;where&quot;</span> prefixOverrides=<span class="string">&quot;and|or&quot;</span>&gt;</span><br><span class="line">                &lt;<span class="keyword">if</span> test=<span class="string">&quot;name!=null&quot;</span>&gt;</span><br><span class="line">                    name=#&#123;name&#125;</span><br><span class="line">                &lt;/<span class="keyword">if</span>&gt;</span><br><span class="line">                &lt;<span class="keyword">if</span> test=<span class="string">&quot;age&amp;lt;25&quot;</span>&gt;</span><br><span class="line">                    and age=#&#123;age&#125;</span><br><span class="line">                &lt;/<span class="keyword">if</span>&gt;</span><br><span class="line">            &lt;/trim&gt;</span><br><span class="line">    &lt;/select&gt;</span><br></pre></td></tr></table></figure>

<blockquote>
<p><strong>choose、when、otherwise标签</strong></p>
</blockquote>
<p>只会有一个满足</p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br></pre></td><td class="code"><pre><span class="line">&lt;select id=<span class="string">&quot;queryById&quot;</span> resultType=<span class="string">&quot;User&quot;</span>&gt;</span><br><span class="line">        select * from user</span><br><span class="line">            &lt;where&gt;</span><br><span class="line">                &lt;choose&gt;</span><br><span class="line">                    &lt;!--只是执行一个--&gt;</span><br><span class="line">                    &lt;when test=<span class="string">&quot;name!=null&quot;</span>&gt;</span><br><span class="line">                        name=#&#123;name&#125;</span><br><span class="line">                    &lt;/when&gt;</span><br><span class="line">                    &lt;when test=<span class="string">&quot;age&amp;lt;25&quot;</span>&gt;</span><br><span class="line">                        age=#&#123;age&#125;</span><br><span class="line">                    &lt;/when&gt;</span><br><span class="line">                    &lt;!--上面都不满足，执行otherwise--&gt;</span><br><span class="line">                    &lt;otherwise&gt;</span><br><span class="line">                        and id=#&#123;id&#125;</span><br><span class="line">                    &lt;/otherwise&gt;</span><br><span class="line">                &lt;/choose&gt;</span><br><span class="line">            &lt;/where&gt;</span><br><span class="line">    &lt;/select&gt;</span><br></pre></td></tr></table></figure>

<blockquote>
<p>&#x3D;&#x3D;<strong>foreach批量操作</strong>&#x3D;&#x3D;</p>
</blockquote>
<ul>
<li><p><strong>批量查询</strong></p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br></pre></td><td class="code"><pre><span class="line">&lt;select id=<span class="string">&quot;batchQuery&quot;</span> resultType=<span class="string">&quot;user&quot;</span>&gt;</span><br><span class="line">        select * from user where id in</span><br><span class="line">        &lt;!--遍历的数据（<span class="number">1</span>,<span class="number">2</span>,<span class="number">3</span>,<span class="number">4</span>）</span><br><span class="line">            collection= <span class="string">&quot;别名&quot;</span> |arg0 | list</span><br><span class="line">            open：遍历之前要加的字符串</span><br><span class="line">            separator:分割符号</span><br><span class="line">            item: 遍历项</span><br><span class="line">        --&gt;</span><br><span class="line">        &lt;foreach collection=<span class="string">&quot;ids&quot;</span> item=<span class="string">&quot;id&quot;</span> open=<span class="string">&quot;(&quot;</span> separator=<span class="string">&quot;,&quot;</span> close=<span class="string">&quot;)&quot;</span>&gt;</span><br><span class="line">            #&#123;id&#125;</span><br><span class="line">        &lt;/foreach&gt;</span><br><span class="line">    &lt;/select&gt;</span><br></pre></td></tr></table></figure>
</li>
<li><p><strong>批量插入</strong></p>
</li>
</ul>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line">&lt;insert id=<span class="string">&quot;batchInset&quot;</span>&gt;</span><br><span class="line">      &lt;!--values((user1),(user2),(user3))--&gt;</span><br><span class="line">      insert into <span class="title function_">user</span><span class="params">(id,name,age)</span> values</span><br><span class="line">      &lt;foreach collection=<span class="string">&quot;userList&quot;</span> item=<span class="string">&quot;user&quot;</span> separator=<span class="string">&quot;,&quot;</span>&gt;</span><br><span class="line">          (#&#123;user.id&#125;,#&#123;user.name&#125;,#&#123;user.age&#125;)</span><br><span class="line">      &lt;/foreach&gt;</span><br><span class="line">  	&lt;/insert&gt;</span><br></pre></td></tr></table></figure>

<ul>
<li>批量删除</li>
</ul>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line">&lt;delete id=<span class="string">&quot;batchDelete&quot;</span>&gt;</span><br><span class="line">        delete from user where id in</span><br><span class="line">                         &lt;foreach collection=<span class="string">&quot;ids&quot;</span> item=<span class="string">&quot;id&quot;</span> open=<span class="string">&quot;(&quot;</span> separator=<span class="string">&quot;,&quot;</span> close=<span class="string">&quot;)&quot;</span>&gt;</span><br><span class="line">                             #&#123;id&#125;</span><br><span class="line">                         &lt;/foreach&gt;</span><br><span class="line">    &lt;/delete&gt;</span><br></pre></td></tr></table></figure>

<ul>
<li><p>批量更新</p>
<p>注意： jdbc:mysql:&#x2F;&#x2F;192.168.253.128:3306&#x2F;user?&#x3D;&#x3D;<strong>allowMultiQueries&#x3D;true</strong>&#x3D;&#x3D;  添加这个才能<strong>执行多条语句</strong></p>
</li>
</ul>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line">&lt;!--最后的分号不能少--&gt;</span><br><span class="line">&lt;update id=<span class="string">&quot;batchUpdate&quot;</span>&gt;</span><br><span class="line">       &lt;foreach collection=<span class="string">&quot;userList&quot;</span> item=<span class="string">&quot;user&quot;</span>&gt;</span><br><span class="line">           update user set name=#&#123;user.name&#125;,age=#&#123;user.age&#125; where id=#&#123;user.id&#125;;</span><br><span class="line">       &lt;/foreach&gt;</span><br><span class="line">   &lt;/update&gt;</span><br></pre></td></tr></table></figure>

<blockquote>
<p><strong>SQL标签</strong></p>
</blockquote>
<p>提取重复的代码片段</p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line">&lt;sql id=<span class="string">&quot;selectSql&quot;</span>&gt;</span><br><span class="line">    select * from user</span><br><span class="line">&lt;/sql&gt;</span><br><span class="line"></span><br><span class="line">&lt;select id=<span class="string">&quot;queryById&quot;</span> resultType=<span class="string">&quot;User&quot;</span>&gt;</span><br><span class="line">    &lt;include refid=<span class="string">&quot;selectSql&quot;</span>/&gt; </span><br><span class="line">    where id=#&#123;id&#125;</span><br><span class="line">&lt;/select&gt;</span><br></pre></td></tr></table></figure>

<h2 id="五、Mybatis高级拓展"><a href="#五、Mybatis高级拓展" class="headerlink" title="五、Mybatis高级拓展"></a>五、Mybatis高级拓展</h2><h3 id="包扫描映射文件"><a href="#包扫描映射文件" class="headerlink" title="包扫描映射文件"></a>包扫描映射文件</h3><p>&#x3D;&#x3D;注意：创建多层文件夹，不能用com.atguigu.mapper创建包，而是用com&#x2F;atguigu&#x2F;mapper&#x3D;&#x3D;</p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line">&lt;mappers&gt;</span><br><span class="line">    &lt;!--批量扫描包</span><br><span class="line">    <span class="keyword">package</span>标签</span><br><span class="line">    <span class="number">1.</span> mapper.xml和mapper接口的名字必须相同</span><br><span class="line">    <span class="number">2.</span> 最后映射文件和接口所在的位置要一致或在resource包中创建相同的文件夹结构</span><br><span class="line">    注意：创建多层文件夹，不能用com.atguigu.mapper创建包，而是用com/atguigu/mapper</span><br><span class="line">    --&gt;</span><br><span class="line">    &lt;<span class="keyword">package</span> name=<span class="string">&quot;com.atguigu.mapper&quot;</span>/&gt;</span><br></pre></td></tr></table></figure>

<h3 id="分页插件"><a href="#分页插件" class="headerlink" title="分页插件"></a>分页插件</h3><p><img src="https://gitee.com/htt-sub/pic-go/raw/master/images/image-20231029093137490.png" alt="image-20231029093137490"></p>
<p><img src="https://gitee.com/htt-sub/pic-go/raw/master/images/image-20231029093250808.png" alt="image-20231029093250808"></p>
<blockquote>
<p>导入依赖</p>
</blockquote>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">&lt;dependency&gt;</span><br><span class="line">          &lt;groupId&gt;com.github.pagehelper&lt;/groupId&gt;</span><br><span class="line">          &lt;artifactId&gt;pagehelper&lt;/artifactId&gt;</span><br><span class="line">          &lt;version&gt;<span class="number">5.1</span><span class="number">.11</span>&lt;/version&gt;</span><br><span class="line">      &lt;/dependency&gt;</span><br></pre></td></tr></table></figure>

<blockquote>
<p>mybatis-config.xml中配置分页插件</p>
</blockquote>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">&lt;plugins&gt;</span><br><span class="line">       &lt;plugin interceptor=<span class="string">&quot;com.github.pagehelper.PageHelper&quot;</span>&gt;</span><br><span class="line">           &lt;property name=<span class="string">&quot;helperDialect&quot;</span> value=<span class="string">&quot;mysql&quot;</span>/&gt;</span><br><span class="line">       &lt;/plugin&gt;</span><br><span class="line">   &lt;/plugins&gt;</span><br></pre></td></tr></table></figure>

<blockquote>
<p>映射文件</p>
</blockquote>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">&lt;select id=<span class="string">&quot;queryAll&quot;</span> resultType=<span class="string">&quot;user&quot;</span>&gt;</span><br><span class="line">       &lt;!--使用分页插件，注意：结尾不能用分号--&gt;</span><br><span class="line">       select * from user</span><br><span class="line">   &lt;/select&gt;</span><br></pre></td></tr></table></figure>

<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">//获取接口代理对象，调用代理对象的方法</span></span><br><span class="line"><span class="type">UserMapper</span> <span class="variable">mapper</span> <span class="operator">=</span> sqlSession.getMapper(UserMapper.class);</span><br><span class="line"></span><br><span class="line">PageHelper.startPage(<span class="number">2</span>,<span class="number">4</span>);</span><br><span class="line">List&lt;User&gt; users = mapper.queryAll();</span><br><span class="line"><span class="comment">//将查询数据封装到一个PageInfo的分页实体类</span></span><br><span class="line">PageInfo&lt;User&gt; pageInfo = <span class="keyword">new</span> <span class="title class_">PageInfo</span>&lt;&gt;(users);</span><br><span class="line"></span><br><span class="line"><span class="comment">//获取分页数据</span></span><br><span class="line">List&lt;User&gt; list = pageInfo.getList();</span><br><span class="line">System.out.println(<span class="string">&quot;当前页数据：&quot;</span>+list);</span><br><span class="line"><span class="comment">//当前总页数</span></span><br><span class="line"><span class="type">int</span> <span class="variable">pages</span> <span class="operator">=</span> pageInfo.getPages();</span><br><span class="line">System.out.println(<span class="string">&quot;当前总页数：&quot;</span>+pages);</span><br><span class="line"><span class="comment">//获取总条数</span></span><br><span class="line"><span class="type">long</span> <span class="variable">total</span> <span class="operator">=</span> pageInfo.getTotal();</span><br><span class="line">System.out.println(<span class="string">&quot;总条数：&quot;</span>+total);</span><br></pre></td></tr></table></figure>

<h3 id="逆向工程："><a href="#逆向工程：" class="headerlink" title="逆向工程："></a>逆向工程：</h3><p><strong>自动生成单表的增删改查</strong></p>
<blockquote>
<p><strong>MybatisX插件</strong></p>
</blockquote>
<ol>
<li>IDEA连接数据库</li>
<li>选中要生成的表</li>
</ol>
<h2 id="六、总结"><a href="#六、总结" class="headerlink" title="六、总结"></a>六、总结</h2><p><img src="https://gitee.com/htt-sub/pic-go/raw/master/images/image-20231029101137903.png" alt="image-20231029101137903"></p>

      
    </div>
    
    
    

    

    

    

    <footer class="post-footer">
      
        <div class="post-tags">
          
            <a href="/tags/mybatis/" rel="tag"># mybatis</a>
          
        </div>
      

      
      
      

      
        <div class="post-nav">
          <div class="post-nav-next post-nav-item">
            
              <a href="/2023/10/24/Spring/" rel="next" title="Spring">
                <i class="fa fa-chevron-left"></i> Spring
              </a>
            
          </div>

          <span class="post-nav-divider"></span>

          <div class="post-nav-prev post-nav-item">
            
              <a href="/2023/10/29/SpringMVC/" rel="prev" title="SpringMVC">
                SpringMVC <i class="fa fa-chevron-right"></i>
              </a>
            
          </div>
        </div>
      

      
      
    </footer>
  </div>
  
  
  
  </article>



    <div class="post-spread">
      
    </div>
  </div>


          </div>
          


          

  



        </div>
        
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    
    <div class="sidebar-inner">

      

      
        <ul class="sidebar-nav motion-element">
          <li class="sidebar-nav-toc sidebar-nav-active" data-target="post-toc-wrap">
            文章目录
          </li>
          <li class="sidebar-nav-overview" data-target="site-overview-wrap">
            站点概览
          </li>
        </ul>
      

      <section class="site-overview-wrap sidebar-panel">
        <div class="site-overview">
          <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
            
              <img class="site-author-image" itemprop="image"
                src="/images/avatar.png"
                alt="" />
            
              <p class="site-author-name" itemprop="name"></p>
              <p class="site-description motion-element" itemprop="description"></p>
          </div>

          <nav class="site-state motion-element">

            
              <div class="site-state-item site-state-posts">
              
                <a href="/archives">
              
                  <span class="site-state-item-count">10</span>
                  <span class="site-state-item-name">日志</span>
                </a>
              </div>
            

            
              
              
              <div class="site-state-item site-state-categories">
                <a href="/categories/index.html">
                  <span class="site-state-item-count">6</span>
                  <span class="site-state-item-name">分类</span>
                </a>
              </div>
            

            
              
              
              <div class="site-state-item site-state-tags">
                <a href="/tags/index.html">
                  <span class="site-state-item-count">8</span>
                  <span class="site-state-item-name">标签</span>
                </a>
              </div>
            

          </nav>

          

          

          
          

          
          

          

        </div>
      </section>

      
      <!--noindex-->
        <section class="post-toc-wrap motion-element sidebar-panel sidebar-panel-active">
          <div class="post-toc">

            
              
            

            
              <div class="post-toc-content"><ol class="nav"><li class="nav-item nav-level-2"><a class="nav-link" href="#Mybatis"><span class="nav-number">1.</span> <span class="nav-text">Mybatis</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E4%B8%80%E3%80%81%E7%AE%80%E4%BB%8B"><span class="nav-number">2.</span> <span class="nav-text">一、简介</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#%E5%AE%98%E6%96%B9%E6%96%87%E6%A1%A3"><span class="nav-number">2.1.</span> <span class="nav-text">官方文档</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#%E5%BF%AB%E9%80%9F%E5%85%A5%E9%97%A8"><span class="nav-number">2.2.</span> <span class="nav-text">快速入门</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#Mybatis%E5%8E%9F%E7%90%86"><span class="nav-number">2.3.</span> <span class="nav-text">Mybatis原理</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E4%BA%8C%E3%80%81%E5%9F%BA%E6%9C%AC%E4%BD%BF%E7%94%A8"><span class="nav-number">3.</span> <span class="nav-text">二、基本使用</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#2-1-%E5%90%91SQL%E8%AF%AD%E5%8F%A5%E4%BC%A0%E5%8F%82"><span class="nav-number">3.1.</span> <span class="nav-text">2.1 向SQL语句传参</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#2-2-%E5%92%8C-%E5%8C%BA%E5%88%AB"><span class="nav-number">3.2.</span> <span class="nav-text">2.2 #{}和${}区别</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#2-3-%E5%8D%95%E4%B8%AA%E5%AE%9E%E4%BD%93%E7%B1%BB%E6%8F%92%E5%85%A5"><span class="nav-number">3.3.</span> <span class="nav-text">2.3 单个实体类插入</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#2-4-%E5%A4%9A%E4%B8%AA%E7%AE%80%E5%8D%95%E7%B1%BB%E5%9E%8B%E4%BC%A0%E5%85%A5"><span class="nav-number">3.4.</span> <span class="nav-text">2.4 多个简单类型传入</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#2-3-%E8%BF%94%E5%9B%9E%E7%B1%BB%E5%9E%8B"><span class="nav-number">3.5.</span> <span class="nav-text">2.3 返回类型</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#2-4-%E8%BF%94%E5%9B%9EMap%E7%B1%BB%E5%9E%8B"><span class="nav-number">3.6.</span> <span class="nav-text">2.4 返回Map类型</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#2-5-%E8%BF%94%E5%9B%9EList%E7%B1%BB%E5%9E%8B"><span class="nav-number">3.7.</span> <span class="nav-text">2.5 返回List类型</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#2-6-%E8%87%AA%E5%8A%A8%E6%8F%90%E4%BA%A4%E4%BA%8B%E5%8A%A1%E5%92%8C%E8%87%AA%E5%A2%9E%E4%B8%BB%E9%94%AE"><span class="nav-number">3.8.</span> <span class="nav-text">2.6 自动提交事务和自增主键</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#%E8%87%AA%E5%AE%9A%E4%B9%89%E6%98%A0%E5%B0%84%E5%85%B3%E7%B3%BBresultMap"><span class="nav-number">3.9.</span> <span class="nav-text">自定义映射关系resultMap</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E4%B8%89%E3%80%81%E5%A4%9A%E8%A1%A8%E6%98%A0%E5%B0%84"><span class="nav-number">4.</span> <span class="nav-text">三、多表映射</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#%E6%80%BB%E7%BB%93"><span class="nav-number">4.1.</span> <span class="nav-text">总结</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E5%9B%9B%E3%80%81%E5%8A%A8%E6%80%81%E8%AF%AD%E5%8F%A5"><span class="nav-number">5.</span> <span class="nav-text">四、动态语句</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E4%BA%94%E3%80%81Mybatis%E9%AB%98%E7%BA%A7%E6%8B%93%E5%B1%95"><span class="nav-number">6.</span> <span class="nav-text">五、Mybatis高级拓展</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#%E5%8C%85%E6%89%AB%E6%8F%8F%E6%98%A0%E5%B0%84%E6%96%87%E4%BB%B6"><span class="nav-number">6.1.</span> <span class="nav-text">包扫描映射文件</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#%E5%88%86%E9%A1%B5%E6%8F%92%E4%BB%B6"><span class="nav-number">6.2.</span> <span class="nav-text">分页插件</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#%E9%80%86%E5%90%91%E5%B7%A5%E7%A8%8B%EF%BC%9A"><span class="nav-number">6.3.</span> <span class="nav-text">逆向工程：</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E5%85%AD%E3%80%81%E6%80%BB%E7%BB%93"><span class="nav-number">7.</span> <span class="nav-text">六、总结</span></a></li></ol></div>
            

          </div>
        </section>
      <!--/noindex-->
      

      

    </div>
  </aside>


        
      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <div class="copyright">&copy; <span itemprop="copyrightYear">2023</span>
  <span class="with-love">
    <i class="fa fa-user"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">黄宏涛</span>

  
</div>


  <div class="powered-by">由 <a class="theme-link" target="_blank" href="https://hexo.io">Hexo</a> 强力驱动</div>



  <span class="post-meta-divider">|</span>



  <div class="theme-info">主题 &mdash; <a class="theme-link" target="_blank" href="https://github.com/iissnan/hexo-theme-next">NexT.Gemini</a> v5.1.4</div>




        







        
      </div>
    </footer>

    
      <div class="back-to-top">
        <i class="fa fa-arrow-up"></i>
        
      </div>
    

    

  </div>

  

<script type="text/javascript">
  if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
    window.Promise = null;
  }
</script>









  


  











  
  
    <script type="text/javascript" src="/lib/jquery/index.js?v=2.1.3"></script>
  

  
  
    <script type="text/javascript" src="/lib/fastclick/lib/fastclick.min.js?v=1.0.6"></script>
  

  
  
    <script type="text/javascript" src="/lib/jquery_lazyload/jquery.lazyload.js?v=1.9.7"></script>
  

  
  
    <script type="text/javascript" src="/lib/velocity/velocity.min.js?v=1.2.1"></script>
  

  
  
    <script type="text/javascript" src="/lib/velocity/velocity.ui.min.js?v=1.2.1"></script>
  

  
  
    <script type="text/javascript" src="/lib/fancybox/source/jquery.fancybox.pack.js?v=2.1.5"></script>
  

  
  
    <script type="text/javascript" src="/lib/canvas-nest/canvas-nest.min.js"></script>
  


  


  <script type="text/javascript" src="/js/src/utils.js?v=5.1.4"></script>

  <script type="text/javascript" src="/js/src/motion.js?v=5.1.4"></script>



  
  


  <script type="text/javascript" src="/js/src/affix.js?v=5.1.4"></script>

  <script type="text/javascript" src="/js/src/schemes/pisces.js?v=5.1.4"></script>



  
  <script type="text/javascript" src="/js/src/scrollspy.js?v=5.1.4"></script>
<script type="text/javascript" src="/js/src/post-details.js?v=5.1.4"></script>



  


  <script type="text/javascript" src="/js/src/bootstrap.js?v=5.1.4"></script>



  


  




	





  





  












  





  

  

  

  
  

  

  

  

</body>
</html>
